'use strict';

const Controller = require('egg').Controller;
const userLogin = require('../middleware/userLogin.js')
class UserController extends Controller {
    async certificate () {
        const { ctx } = this;
        console.log(ctx);
        const body = await ctx.request.body;
        // 请求微信服务器获取用户的openId
        const userInfoFromWe = await userLogin.login(body.code)
        console.log("userInfoFromWe-------",userInfoFromWe);
        const token = await ctx.service.user.updateUser(userInfoFromWe) // 获取用户信息
        // console.log("userInfo",userInfo);
        ctx.body = {
            code:token,
            msg:'请求成功,这是一个token',
           // ...userInfoFromWe
        };
    }
}

module.exports = UserController;
